/**
 * IO函子,把有副作用的操作扔给调用者调用，函子还是保持纯函数
 */
const fp = require("lodash/fp");
class IO{
  static of(value){
    return new IO(()=>{
      return value;
    })
  }

  constructor(fn){
    this._value = fn
  }

  map(fn){
    return new IO(fp.flowRight(fn,this._value));
  }
}

const f = IO.of(process).map(x=>x.execPath);
console.log(f);
console.log(f._value())
// console.log(process)